package com.naicheng.ivote.views.fragments;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;

import com.naicheng.ivote.R;
import com.naicheng.ivote.doman.TestListRes;
import com.naicheng.ivote.engin.BaseFragment;
import com.naicheng.ivote.views.TestDetailQuestionActivity;

public class TestDetailFragment extends BaseFragment {

	@Override
	protected View initViews(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.test_shw_detail, null, false);
	}

	protected void init() {
		TextView tv_score = getView(R.id.tv_score);
		TextView tv_content = getView(R.id.tv_content);
		
		tv_score.setTextColor(Color.GRAY);
		tv_content.setTextColor(Color.WHITE);
		TestListRes data = ctx.getItem();
		if(data!=null){
			tv_content.setText(data.content);
			tv_score.setText("此题送积分："+data.integral+"分");
		} else {
			getView(R.id.bt_start_test).setVisibility(View.GONE);
		}
		
		getView(R.id.bt_start_test).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				ctx.startText();
			}
		});
	};
	
	TestDetailQuestionActivity ctx;
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		ctx = (TestDetailQuestionActivity) activity;
	}
}
